home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / c_toolbx.arc / FDE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1988-03-30  |  1.2 KB  |  49 lines

  1. /* fd.c - FD program - main function */
  2. #include "stdio.h"
  3. #include "cminor.h"
  4. #include "viewcmds.h"
  5. #include "fdparm.h"
  6.  
  7. char filename[65] = ""  ;
  8.  
  9. main(argc,argv)
  10.   int    argc  ;
  11.   char    *argv[]  ;
  12.   {
  13.      int   cmd    ;            /* holds current command    */
  14.  
  15.      if( argc >= 2 )            /* get file name from command    */
  16.     strcpy(filename,argv[1])  ;    /* line ( if present )    */
  17.  
  18.      init_disp()  ;            /* initalize for display    */
  19.      get_filename(filename)  ;        /* get file name & open file    */
  20.      set_filesize(BIN_MODE)  ;        /* set up filesize variable    */
  21.      cmd = FIRSTPAGE  ;         /* froce display to first page    */
  22.  
  23.      while( cmd != EXITPGM )        /* repeat until told to exit    */
  24.     {  exec_cmd(cmd)  ;        /* execute current command    */
  25.        cmd = get_cmd()  ;        /* get next command    */
  26.     }
  27.  
  28.      close_file()  ;
  29.   }
  30.  
  31.  
  32. int  get_filename(fn)            /* get name of file & open it    */
  33.   char    fn[]  ;             /* file name string    */
  34.   {                    /* filled out by caller */
  35.      if( stelen(fn) == 0  )
  36.     {  printf("file name:")  ;
  37.        scanf("%s",fn)  ;
  38.     }
  39.  
  40.      while( open_file(fn) == FAILURE)    /* open file (verify name)    */
  41.     {  printf("\n file - %s can not be opened\n")  ;
  42.        printf("file name:")  ;      /* try again    */
  43.        scanf("%s",fn)  ;
  44.     }
  45.   }
  46.  
  47.  
  48.  
  49.